<?php
/**
 * Created by dzw.
 * User: Administrator
 * Date: 2018-03-16
 * Time: 10:22
 */

namespace App\Http\Controllers\Web\Member\Buyer;

use App\Http\Controllers\Web\BaseController;
use Illuminate\Http\Request;

class ReportController extends BaseController
{
    protected $api_url = [
        'index' => ['get',  'buyer/report'],
        'store' => ['post', 'buyer/report'],
        'create'=> ['get',  'buyer/report_add'],
    ];
    protected $api_host;

    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
        $this->api_host = config('url.api_web');
    }

    public function index()
    {
        //请求部分
        $ret =  http_web($this->api_url['index'])->send();

        //结果处理部分
        $data = [];
        if(isset($ret['code']) && $ret['code']===0 && !empty($ret['data'])){
            $data = $ret['data'];
        }

        //回填搜索框值
        return view('web.user.buyer.report', $data);

    }

    public function create()
    {
        //请求部分
        $ret =  http_web($this->api_url['create'])->send();

        //结果处理部分
        $data = [];
        if(isset($ret['code']) && $ret['code']===0 && !empty($ret['data'])){
            $data = $ret['data'];
        }
        //结果处理部分
        return view('web.user.buyer.report_add',$data);
    }
    public function store()
    {
        //请求部分
        $data = $this->request->all();
        $data['user_id'] = 2;

        $ret = http_web($this->api_url['store'])->send($data);

        //结果处理部分
        return response()->json($ret);
    }



}